package cn.module.component
{
	import mx.controls.Button;
	import mx.controls.LinkBar;

	/** 增删改的linkbar使用 */
	public class ChildLinkBar extends LinkBar
	{
		public function ChildLinkBar()
		{
			super();
		}
		private var showArr:Array = new Array();  //存放显示的图标
		private var noShowArr:Array = new Array();  //存放不显示时的图标

		override protected function hiliteSelectedNavItem(index:int):void
        {
             var child:Button;

            // Un-hilite the current selection. 选中后，灰显或者取消灰显。本例中不改变——仍然显示
//            if (selectedIndex != -1 && selectedIndex < numChildren)
//            {
//                child = Button(getChildAt(selectedIndex));
//                child.enabled = true;
//            }

            // Set new index.不起作用
//            super.selectedIndex = index;
            
            if(index <20){
            	//不显示
            	child = Button(getChildAt(index));
            	if(noShowArr.length != 0){  //为了兼容以前代码，加的判断
            	    child.setStyle("icon",noShowArr[index]); //使用这种方式改变图标
            	}
            	child.enabled = false;
            }
            if(index >= 20){
            	//显示
            	child = Button(getChildAt(index-20));
            	if(noShowArr.length != 0){
            	    child.setStyle("icon",noShowArr[index-20]);
            	}
            	child.enabled = true;
            }
        }
        public function enabledItem(index:int):void{
        	this.hiliteSelectedNavItem(index);
        }
        public function inputIconArr(show:Array, noShow:Array):void{
        	//通过此方法，将图片传入，并对应到index
        	this.showArr = show;
        	this.noShowArr = noShow;
        }
   }
		
}